//
//  AXHomeZjzdSecondCell.m
//  AnXin100
//
//  Created by 天质弘耕 on 2018/10/24.
//  Copyright © 2018年 tzhg. All rights reserved.
//
/** 列表 */
#import "AXHomeZjzdSecondCell.h"
#import "ZXCategories.h"
#import "UITableView+SDAutoTableViewCellHeight.h"
#import "UIImageView+WebCache.h"

@interface AXHomeZjzdSecondCell ()
/** 线 */
@property (nonatomic , strong) UIView *lineView;

@end

@implementation AXHomeZjzdSecondCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
      
        [self creatView];
      
    }
    return self;
}


- (void)creatView {
    
    /** 专家图片 */
    self.specialistImg = [[UIImageView alloc]init];
    self.specialistImg.cornerRadius = 30;
    self.specialistImg.contentMode =UIViewContentModeScaleAspectFill;
    self.specialistImg.clipsToBounds=YES;//
    [self.contentView addSubview:self.specialistImg];
    
    /** 专家名字 */
    self.specialistNameLabel = [[UILabel alloc]init];
    self.specialistNameLabel.textColor = COLOR_DIV;
    self.specialistNameLabel.font = FONT_FOURTEEN;
    [self.contentView addSubview:self.specialistNameLabel];
    
    /** 性别 */
    self.specialistSexLabel = [[UILabel alloc]init];
    self.specialistSexLabel.textColor = COLOR_DIV;
    self.specialistSexLabel.font = FONT_FOURTEEN;
    [self.contentView addSubview:self.specialistSexLabel];
    /** 职称 */
    self.jobTitleLabel = [[UILabel alloc]init];
    self.jobTitleLabel.textColor = COLOR_DIV;
    self.jobTitleLabel.font = FONT_FOURTEEN;
    [self.contentView addSubview:self.jobTitleLabel];
    /** 满意度 */
    self.satisfactionLabel = [[UILabel alloc]init];
    self.satisfactionLabel.textColor = COLOR_ORG;
    self.satisfactionLabel.font = FONT_FOURTEEN;
    [self.contentView addSubview:self.satisfactionLabel];
    /** 大学 */
    self.universityLabel = [[UILabel alloc]init];
    self.universityLabel.textColor = COLOR_DIV;
    self.universityLabel.font = FONT_FOURTEEN;
    [self.contentView addSubview:self.universityLabel];
    
    /** 擅长*/
    self.wellLabel = [[UILabel alloc]init];
    self.wellLabel.textColor = COLOR_DIV;
    self.wellLabel.font = FONT_FOURTEEN;
    [self.contentView addSubview:self.wellLabel];
    
    self.cropLabel = [[UILabel alloc]init];
    self.cropLabel.textColor = COLOR_DIV;
    self.cropLabel.font = FONT_FOURTEEN;
    [self.contentView addSubview:self.cropLabel];
    
 
    /** 立即咨询 */
    self.consultLabel = [[UIButton alloc]init];
    [self.consultLabel addTarget:self action:@selector(tapAction:) forControlEvents:UIControlEventTouchUpInside];
    [_consultLabel setTitle:@"立即咨询" forState:UIControlStateNormal];
    [_consultLabel setTitleColor:COLOR_GREEN forState:UIControlStateNormal];
    [self.contentView addSubview:self.consultLabel];
   
    /** 线 */
    self.lineView = [[UIView alloc]init];
    self.lineView.backgroundColor = COLOR_LINE;
    [self.contentView addSubview:self.lineView];
    
    
}

- (void)setlayout {
    
    /** 专家图片 */
    self.specialistImg.sd_layout
    .leftSpaceToView(self.contentView, 10)
    .topSpaceToView(self.contentView, 50)
    .widthIs(60)
    .heightIs(60);
    
    /** 专家名字 */
    self.specialistNameLabel.sd_layout
    .leftSpaceToView(self.contentView, 70)
    .topSpaceToView(self.contentView, 10)
    .widthIs(100)
    .heightIs(20);
 
   
    /** 满意度 */
    self.satisfactionLabel.sd_layout
    .rightSpaceToView(self.contentView, 10)
    .topSpaceToView(self.contentView, 10)
    .widthIs(100)
    .heightIs(30);
    /** 大学 */
   self.universityLabel.sd_layout
    .leftSpaceToView(self.contentView, 70)
    .topSpaceToView(self.specialistNameLabel, 10)
    .widthIs(120)
    .heightIs(20);
    
    /** 职称 */
    self.jobTitleLabel.sd_layout
    .leftSpaceToView(self.universityLabel, 10)
    .topSpaceToView(self.specialistSexLabel, 10)
    .rightSpaceToView(self.contentView, 10)
    .heightIs(20);
    
    /** 性别 */
    self.specialistSexLabel.sd_layout
    .leftSpaceToView(self.universityLabel, 10)
    .topEqualToView(self.specialistNameLabel)
    .widthIs(20)
    .heightIs(20);
   
    /** 擅长*/
    self.wellLabel.sd_layout
    .leftSpaceToView(self.contentView, 70)
    .topSpaceToView(self.universityLabel, 10)
    .widthIs(SCREEN_WIDTH-80)
    .autoHeightRatio(0)
    .minHeightIs(20);
    
    /** 作物*/
    self.cropLabel.sd_layout
    .leftSpaceToView(self.contentView, 70)
    .topSpaceToView(self.wellLabel, 10)
    .widthIs(SCREEN_WIDTH-80)
    .heightIs(20);
    
    
     /** 立即咨询*/
    self.consultLabel.sd_layout
    .rightSpaceToView(self.contentView, 10)
    .topSpaceToView(self.cropLabel, 10)
    .widthIs(100)
    .heightIs(30);
   
    
    self.lineView.sd_layout
    .leftSpaceToView(self.contentView, 0)
    .rightSpaceToView(self.contentView, 0)
    .topSpaceToView(self.consultLabel, 10)
    .heightIs(10);
    
    
    /** cell自适应第一步 */
    [self setupAutoHeightWithBottomView:self.lineView bottomMargin:10];
    
}


- (void)setModel:(AXHomeZjzdSecondModel *)model {
    
    _model = model;
    [_specialistImg sd_setImageWithURL:[NSURL URLWithString:_model.fProfilePhoto] placeholderImage:[UIImage imageNamed:@"placeHold"]];
    _specialistNameLabel.text = _model.fName;
    _specialistSexLabel.text = _model.fSexCHS;
    /** 职称 */
    _jobTitleLabel.text = _model.fPositionalTitleName;
    _satisfactionLabel.text = [NSString stringWithFormat:@"满意度:%@%%",_model.fSatisfiedPer];
    _universityLabel.text = [NSString stringWithFormat:@"学校:%@",_model.fCompanyName];
    _wellLabel.text = [NSString stringWithFormat:@"擅长领域:%@", _model.beGoodAtFieldName];
    _cropLabel.text = [NSString stringWithFormat:@"擅长作物:%@",_model.beGoodAtCropsName];
    
    
    [self setlayout];
}



- (void)tapAction:(UIButton *)btn {
    
    if (self.tapCelllickedBlock) {
        
        self.tapCelllickedBlock(btn.tag);
    }
}

@end
